
import java.net.*;
import java.io.Serializable;

public class HitInformation implements Serializable
{
	private static final long serialVersionUID = 8083591979898755187L;
	
	private String[]	absoluteFilePaths;
	private long[]		fileSizes;
	private InetAddress destIP;
	private int			destPort;
	
	public HitInformation
			( String[]    absoluteFilePaths,
			  long[]	  fileSizes,
			  InetAddress destIP,
			  int		  destPort )
	{
		this.absoluteFilePaths = absoluteFilePaths;
		this.fileSizes 		   = fileSizes;
		this.destIP 		   = destIP;
		this.destPort 		   = destPort;
	}
	
	public String[] getFileNames()
	{
		String[] fileNames = new String[ absoluteFilePaths.length ];
		
		for( int f = 0; f < fileNames.length; f++ )
		{
			String[] split = absoluteFilePaths[ f ].split( "/" );
			fileNames[ f ] = split[ split.length - 1 ];
		}
		
		return fileNames;
	}

	public String getFileName
			( int fileNum )
	{
		String[] split = absoluteFilePaths[ fileNum ].split( "/" );
		return split[ split.length - 1 ];
	}
	
	public String getAbsoluteFilePath
			( int fileNum )
	{
		return absoluteFilePaths[ fileNum ];
	}
	
	public long[] getFileSizes()
	{
		return fileSizes;
	}
	
	public InetAddress getDestIP()
	{
		return destIP;
	}
	
	public int getDestPort()
	{
		return destPort;
	}

	public int getNumHits()
	{
		return absoluteFilePaths.length;
	}
	
	public boolean isEmpty(){
		return absoluteFilePaths.length == 0;
	}
	
	public String toString(){
		String result = "";
		result += destIP;
		result += "\t" + destPort + "\n";
		String[] tempArray = getFileNames();
		for( int x = 0; x < absoluteFilePaths.length; x++ ){
			result += "\t" + x + "\t" + tempArray[x];
			result += "\t" + fileSizes[x] + "\n";
		}
		
		return result;
	}
}
